//预加载脚本,运行在浏览器环境，渲染进程里面，
//能访问部分node的api
console.log('preload')

const {contextBridge,ipcRenderer} = require('electron')
contextBridge.exposeInMainWorld('myAPI',{
  version:process.version,
  saveFile:(data)=>{
    ipcRenderer.send('file-save',data)
  },
  readFile(){
    return ipcRenderer.invoke('file-read')
  }
})

// window.addEventListener('DOMContentLoaded', () => {
//   const replaceText = (selector, text) => {
//     const element = document.getElementById(selector)
//     if (element) element.innerText = text
//   }

//   for (const type of ['chrome', 'node', 'electron']) {
//     replaceText(`${type}-version`, process.versions[type])
//   }
// })
